import {defineStore} from 'pinia'

export default defineStore("user", {
    state() {
        return {
            user: {
                userId: ""
            }
        }
    },
    actions: {
        setUser(user: UserBean) {
            this.user = user
            sessionStorage.setItem("user", JSON.stringify(user))
        },
        clearUser() {
            this.user = {userId: ""}
            sessionStorage.removeItem("user")
        }
    }
})

export type UserBean = {
    userId: string
}